using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class ObservationResultStatusCodesInterpretationAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public ObservationResultStatusCodesInterpretationAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v23] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v231] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v24] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v25] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v251] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v26] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v27] = HL7TableType.HL7;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v23] = new string[]{"C","D","F","I","P","R","S","U","X"};
						validVersionCodes[HL7Version.v231] = new string[]{"C","D","F","I","N","O","P","R","S","X","U","W"};
						validVersionCodes[HL7Version.v24] = new string[]{"C","D","F","I","N","O","P","R","S","X","U","W"};
						validVersionCodes[HL7Version.v25] = new string[]{"C","D","F","I","N","O","P","R","S","X","U","W"};
						validVersionCodes[HL7Version.v251] = new string[]{"C","D","F","I","N","O","P","R","S","X","U","W"};
						validVersionCodes[HL7Version.v26] = new string[]{"C","D","F","I","N","O","P","R","S","X","U","W"};
						validVersionCodes[HL7Version.v27] = new string[]{"C","D","F","I","N","O","P","R","S","X","U","W"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v23] = new string[]{"Record coming over is a correction and thus replaces a final result","Deletes the OBX record","Final results;  Can only be changed with a corrected result.","Specimen in lab; results pending","Preliminary results","Results entered -- not verified","Partial results","Results status change to Final.  Results did not change (don't transmit test).  E.g., radiology changes status from preliminary to final","Results cannot be obtained for this observation"};
						validVersionDescriptions[HL7Version.v231] = new string[]{"Record coming over is a correction and thus replaces a final result","Deletes the OBX record","Final results; Can only be changed with a corrected result.","Specimen in lab; results pending","Not asked; used to affirmatively document that the observation identified in the OBX was not sought when the universal service ID in OBR-4 implies that it would be sought.","Order detail description only (no result)","Preliminary results","Results entered -- not verified","Partial results","Results cannot be obtained for this observation","Results status change to final without retransmitting results already sent as ‘preliminary.’  E.g., radiology changes status from preliminary to final","Post original as wrong, e.g., transmitted for wrong patient"};
						validVersionDescriptions[HL7Version.v24] = new string[]{"Record coming over is a correction and thus replaces a final result","Deletes the OBX record","Final results; Can only be changed with a corrected result.","Specimen in lab; results pending","Not asked; used to affirmatively document that the observation identified in the OBX was not sought when the universal service ID in OBR-4 implies that it would be sought.","Order detail description only (no result)","Preliminary results","Results entered -- not verified","Partial results","Results cannot be obtained for this observation","Results status change to final without retransmitting results already sent as 'preliminary.'  E.g., radiology changes status from preliminary to final","Post original as wrong, e.g., transmitted for wrong patient"};
						validVersionDescriptions[HL7Version.v25] = new string[]{"Record coming over is a correction and thus replaces a final result","Deletes the OBX record","Final results; Can only be changed with a corrected result.","Specimen in lab; results pending","Not asked; used to affirmatively document that the observation identified in the OBX was not sought when the universal service ID in OBR-4 implies that it would be sought.","Order detail description only (no result)","Preliminary results","Results entered -- not verified","Partial results","Results cannot be obtained for this observation","Results status change to final without retransmitting results already sent as \"preliminary\".  E.g., radiology changes status from preliminary to final","Post original as wrong, e.g., transmitted for wrong patient"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"Record coming over is a correction and thus replaces a final result","Deletes the OBX record","Final results; Can only be changed with a corrected result.","Specimen in lab; results pending","Not asked; used to affirmatively document that the observation identified in the OBX was not sought when the universal service ID in OBR-4 implies that it would be sought.","Order detail description only (no result)","Preliminary results","Results entered -- not verified","Partial results","Results cannot be obtained for this observation","Results status change to final without retransmitting results already sent as âpreliminary.'  E.g., radiology changes status from preliminary to final","Post original as wrong, e.g., transmitted for wrong patient"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"Record coming over is a correction and thus replaces a final result","Deletes the OBX record","Final results; Can only be changed with a corrected result.","Specimen in lab; results pending","Not asked; used to affirmatively document that the observation identified in the OBX was not sought when the universal service ID in OBR-4 implies that it would be sought.","Order detail description only (no result)","Preliminary results","Results entered -- not verified","Partial results.   Deprecated. Retained only for backward compatibility as of V2.6.","Results cannot be obtained for this observation","Results status change to final without retransmitting results already sent as 'preliminary.'  E.g., radiology changes status from preliminary to final","Post original as wrong, e.g., transmitted for wrong patient"};
						validVersionDescriptions[HL7Version.v27] = new string[]{"Record coming over is a correction and thus replaces a final result","Deletes the OBX record","Final results; Can only be changed with a corrected result.","Specimen in lab; results pending","Not asked; used to affirmatively document that the observation identified in the OBX was not sought when the universal service ID in OBR-4 implies that it would be sought.","Order detail description only (no result)","Preliminary results","Results entered -- not verified","Partial results.   Deprecated. Retained only for backward compatibility as of V2.6.","Results cannot be obtained for this observation","Results status change to final without retransmitting results already sent as 'preliminary.'  E.g., radiology changes status from preliminary to final","Post original as wrong, e.g., transmitted for wrong patient"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
